<template>
    <div class="pageContainer">
        <el-row :gutter="20">
            <el-col :span="6" v-if="panels.length == 0" v-for="(item1, index1) in 4" :key="index1">
                <el-skeleton style="width: 100%" :loading="loading" animated>
                    <template #template>
                        <el-card shadow="hover">
                            <template #header>
                                <div class="flex justify-between items-center">
                                    <el-skeleton-item variant="text" style="width: 40%" />
                                    <el-skeleton-item variant="text" style="width: 10%" />
                                </div>
                            </template>
                            <div style="text-align: left;">
                                <el-skeleton-item variant="h1" style="width: 80%" />
                            </div>
                            <template #footer>
                                <div class="flex justify-between items-center text-gray-500 text-sm">
                                    <el-skeleton-item variant="text" style="width: 40%" />
                                    <el-skeleton-item variant="text" style="width: 10%" />
                                </div>
                            </template>
                        </el-card>
                    </template>
                </el-skeleton>
            </el-col>
            <el-col :span="6" v-for="(item, index) in panels" :key="index">
                <el-card shadow="hover">
                    <template #header>
                        <div class="flex justify-between items-center">
                            <span>{{ item.title }}</span>
                            <el-tag :type="item.unitColor" size="normal">{{ item.unit }}</el-tag>
                        </div>
                    </template>
                    <div style="text-align: left;">
                        <span class="text-3xl font-bold text-gray-500">
                            {{ item.value }}
                        </span>
                    </div>
                    <template #footer>
                        <div class="flex justify-between items-center text-gray-500 text-sm">
                            <span>{{ item.subTitle }}</span>
                            <span>{{ item.subValue }}</span>
                        </div>
                    </template>
                </el-card>
            </el-col>
        </el-row>
    </div>
</template>
<script setup>
import { getStatistics1, getStatistics2, getStatistics3 } from '../api/index'
import { ref, onMounted } from 'vue'
import CountTo from '../components/CountTo.vue';

const panels = ref([])

const loadData = async () => {
    const res = await getStatistics1()
    panels.value = res.data.panels
}

onMounted(() => {
    loadData();
});


</script>